<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/9/13
  Time: 16:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>ajax请求</title>
    <script src="/js/jquery-2.1.1.min.js"></script>
    <script>
        $(function () {
            $("#btn").click(function () {
                var name=$("#name").val();
                var sex=$("#sex").val();
                /*将数据发送到、c8/addstudent  参数是name  sex   返回值是data*/
                $.get("/c8/addstudent",{"name":name,"sex":sex},function (data) {
                    console.log(data);
                });

            })

        })
    </script>
</head>
<body>
姓名：<input id="name"><br>
性别：<input id="sex"><br>
<%--因为不是表单提交，不需要submit--%>
<input type="button" value="提交" id="btn">
</body>
</html>
<%--ajax请求要引入js文件--%>